import prisma from "@/src/db/db";
import { NextResponse } from "next/server";

export const GET = async () => {
  const [userCount, orderData] = await Promise.all([
    prisma.user.count(),
    prisma.order.aggregate({
      _sum: { pricePaidInCents: true },
    }),
  ]);
  return NextResponse.json({
    userCount,
    avgValuePerUser: userCount
      ? orderData._sum.pricePaidInCents / userCount
      : 0,
  });
};
